package com.edu.study.base.stuProductItemTemplate.controller;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.stuProductItemTemplate.domain.StuProductItemTemplate;
import com.edu.study.base.stuProductItemTemplate.service.IStuProductItemTemplateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品组件库Controller
 * 
 * @author zw
 * @date 2021-05-11
 */
@RestController
@RequestMapping("/stuProductItemTemplate/stuProductItemTemplate")
public class StuProductItemTemplateController extends BaseController
{
    @Autowired
    private IStuProductItemTemplateService stuProductItemTemplateService;

    /**
     * 查询产品组件库列表
     */
    @PreAuthorize("@ss.hasPermi('stuProductItemTemplate:stuProductItemTemplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuProductItemTemplate stuProductItemTemplate)
    {
        startPage();
        List<StuProductItemTemplate> list = stuProductItemTemplateService.selectStuProductItemTemplateList(stuProductItemTemplate);
        return getDataTable(list);
    }

    @GetMapping("/treeselect")
    public AjaxResult treeselect(StuProductItemTemplate stuProductItemTemplate)
    {
        List<StuProductItemTemplate> stuProductItemTemplateList = stuProductItemTemplateService.selectStuProductItemTemplateList(stuProductItemTemplate);
        return AjaxResult.success(stuProductItemTemplateService.buildTreeSelect(stuProductItemTemplateList));
    }

    /**
     * 导出产品组件库列表
     */
    @PreAuthorize("@ss.hasPermi('stuProductItemTemplate:stuProductItemTemplate:export')")
    @Log(title = "产品组件库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuProductItemTemplate stuProductItemTemplate)
    {
        List<StuProductItemTemplate> list = stuProductItemTemplateService.selectStuProductItemTemplateList(stuProductItemTemplate);
        ExcelUtil<StuProductItemTemplate> util = new ExcelUtil<StuProductItemTemplate>(StuProductItemTemplate.class);
        return util.exportExcel(list, "stuProductItemTemplate");
    }

    /**
     * 获取产品组件库详细信息
     */
    @PreAuthorize("@ss.hasPermi('stuProductItemTemplate:stuProductItemTemplate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(stuProductItemTemplateService.selectStuProductItemTemplateById(id));
    }


    @GetMapping(value = "/getInfoById/{id}")
    public AjaxResult getInfoById(@PathVariable("id") String id)
    {
        return AjaxResult.success(stuProductItemTemplateService.getStuProductItemTemplateById(id));
    }

    /**
     * 新增产品组件库
     */
    @PreAuthorize("@ss.hasPermi('stuProductItemTemplate:stuProductItemTemplate:add')")
    @Log(title = "产品组件库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuProductItemTemplate stuProductItemTemplate)
    {
        stuProductItemTemplate = (StuProductItemTemplate)BeanUtils.initBeanPublicProperties(stuProductItemTemplate,"add");
        return toAjax(stuProductItemTemplateService.insertStuProductItemTemplate(stuProductItemTemplate));
    }

    /**
     * 修改产品组件库
     */
    @PreAuthorize("@ss.hasPermi('stuProductItemTemplate:stuProductItemTemplate:edit')")
    @Log(title = "产品组件库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuProductItemTemplate stuProductItemTemplate)
    {
        stuProductItemTemplate = (StuProductItemTemplate)BeanUtils.initBeanPublicProperties(stuProductItemTemplate,"update");
        return toAjax(stuProductItemTemplateService.updateStuProductItemTemplate(stuProductItemTemplate));
    }

    /**
     * 删除产品组件库
     */
    @PreAuthorize("@ss.hasPermi('stuProductItemTemplate:stuProductItemTemplate:remove')")
    @Log(title = "产品组件库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(stuProductItemTemplateService.deleteStuProductItemTemplateByIds(ids));
    }


}
